import React from "react";
import {
  BrowserRouter as Router,
  Route,
  Switch,
  Redirect
} from "react-router-dom";

import ProtectedRoute from "./components/ProtectedRoute";
import Login from "./pages/Login";
import Dashboard from "./pages/Dashboard";
import SysUser from "./pages/SysUser";
import SysAuthority from "./pages/SysAuthority";
import SysRole from "./pages/SysRole";
import NotFound from "./pages/NotFound";

const RouterApp = () => {
  return (
    <Router>
      <Switch>
        <Route exact path="/login" component={Login} />
        <ProtectedRoute exact path="/dashboard" component={Dashboard} />
        <ProtectedRoute exact path="/sys/user" component={SysUser} />
        <ProtectedRoute exact path="/sys/authority" component={SysAuthority} />
        <ProtectedRoute exact path="/sys/role" component={SysRole} />
        <Route exact path="/" render={props => <Redirect to="/dashboard" />} />
        <Route component={NotFound} />
      </Switch>
    </Router>
  );
};

export default RouterApp;
